Skip to main content

Vec2 Class

Description:

  A class for creating Vec2 objects.

__call

Type: Metamethod.

Description:

  Creates a new Vec2 object from an existing Vec2 object.

Signature:

metamethod __call: function(self: Vec2Class, other: Vec2): Vec2

Usage:

local newVec = Vec2(existingVec)

Parameters:

ParameterTypeDescription
otherVec2The existing Vec2 object to create the new object from.

Returns:

Return TypeDescription
Vec2The new Vec2 object.

__call

Type: Metamethod.

Description:

  Creates a new Vec2 object with the given x and y components.

Signature:

metamethod __call: function(
self: Vec2Class,
x: number,
y: number
): Vec2

Usage:

local newVec = Vec2(10, 20)

Parameters:

ParameterTypeDescription
xnumberThe x-component of the new vector.
ynumberThe y-component of the new vector.

Returns:

Return TypeDescription
Vec2The new Vec2 object.

__call

Type: Metamethod.

Description:

  Creates a new Vec2 object from a Size object.

Signature:

metamethod __call: function(self: Vec2Class, size: Size): Vec2

Usage:

local newVec = Vec2Class(Size(10, 20))

Parameters:

ParameterTypeDescription
sizeSizeThe Size object to create the new vector from.

Returns:

Return TypeDescription
Vec2The new Vec2 object.

zero

Type: Readonly Field.

Description:

  Gets zero-vector object.

Signature:

const zero: Vec2